<?php
include "../includes/conexion.php";
if(isset($_GET["imprimir"])){
	$subsec=$_GET["imprimir"];

session_start();
GLOBAL $consulta;
$consulta=$_SESSION["ultima_consulta"];
function proveedor(){
	echo "
<title>Proveedores Registrados</title>
<h1>Proveedores Registrados</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Rut</th>
                <th width='102' scope='col'>DV</th>
                <th width='109' scope='col'>Nombre</th>
                <th width='230' scope='col'>Direccion</th>
                <th width='171' scope='col'>Comuna</th>
                <th width='123' scope='col'>Ciudad</th>
                <th width='90' scope='col'>Telefono</th>
                <th width='90' scope='col'>Email</th>
                <th width='90' scope='col'>Fax</th>
                <th width='90' scope='col'>Giro</th>
  </tr>
  ";
 global $consulta;//
$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[3]</td>
                <td>$row[4]</td>
                <td>$row[5]</td>
                <td>$row[6]</td>
                <td>$row[7]</td>
                <td><a href='mailto:$row[8]'>$row[8]</a></td>
                <td>$row[9]</td>
                <td>$row[10]</td>
  </tr>

";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	
}

function categoria(){
	echo "
<title>Categorias Registradas</title>
<h1>Categorias Registradas</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
  ";
 global $consulta;
$qry=mysql_query($consulta);//$consulta="select * from cat_categoria";
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>

  </tr>

";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}

function subcategoria(){
	echo "
<title>SubCategoriases Registradas</title>
<h1>SubCategorias Registradas</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Categoria</th>
                <th width='102' scope='col'>Codigo subcategoria</th>
                <th width='102' scope='col'>Descripcion</th>
  ";
 global $consulta;
$qry=mysql_query($consulta);//$consulta="SELECT cat_descripcion,sbc_codigo, sbc_descripcion FROM sbc_subcategoria INNER JOIN cat_categoria ON cat_categoria.cat_codigo= sbc_subcategoria.cat_codigo";
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>

  </tr>

";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function sucursal(){
	echo "
<title>Sucursales Registradas</title>
<h1>Sucursales Registradas</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
                <th width='102' scope='col'>Telefono</th>
                <th width='102' scope='col'>Rut</th>
                <th width='102' scope='col'>Email</th>
  ";
 global $consulta;//$consulta="SELECT * from suc_sucursal";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
                <td>$row[3]</td>
                <td>$row[4]</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function caja(){
	echo "
<title>Cajas Registradas</title>
<h1>Cajas Registradas</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
                <th width='102' scope='col'>Folio Boleta</th>
  ";
 global $consulta;//$consulta="SELECT * from cja_cajas";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function cajero(){
	echo "
<title>Cajeros Registrados</title>
<h1>Cajeros Registrados</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
                <th width='102' scope='col'>Nombre</th>
                <th width='102' scope='col'>Email</th>
                <th width='102' scope='col'>Direccion</th>
                <th width='102' scope='col'>Telefono</th>
                <th width='102' scope='col'>Celular</th>
  ";
 global $consulta;//$consulta="SELECT * from caj_cajeros";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
				<td>$row[3]</td>
                <td>$row[4]</td>
                <td>$row[5]</td>
                <td>$row[6]</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function envase(){
	echo "
<title>Envases Registrados</title>
<h1>Envases Registrados</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
                <th width='102' scope='col'>Sigla</th>
  ";
 global $consulta;//$consulta="SELECT * from env_envase";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function bodega(){
	echo "
<title>Bodegas Registradas</title>
<h1>Bodegas Registrados</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Descripcion</th>
                <th width='102' scope='col'>Jefe</th>
                <th width='102' scope='col'>Email</th>
                <th width='102' scope='col'>Direccion</th>
                <th width='102' scope='col'>Telefono</th>
                <th width='102' scope='col'>Celular</th>
  ";
 global $consulta;//$consulta="SELECT * from bod_bodega";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
				<td>$row[3]</td>
                <td>$row[4]</td>
                <td>$row[5]</td>
                <td>$row[6]</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function pago(){
	echo "
<title>Formas de pagos Registradas</title>
<h1>formas de pagos Registradas</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo</th>
                <th width='102' scope='col'>Glosa</th>
                <th width='102' scope='col'>Afecto IVA</th>
                <th width='102' scope='col'>IMP: Boleta</th>
                <th width='102' scope='col'>Con Costo</th>
  ";
 global $consulta;//$consulta="SELECT * from form_pagos";

$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>";				    		if($row[2]==1){
				    			 echo "Si";
				    		}else{
				    			 echo "No";
				    		}echo"</td>
				<td>";				    		if($row[3]==1){
				    			 echo "Si";
				    		}else{
				    			 echo "No";
				    		}echo"</td>
                <td>";				    		if($row[4]==1){
				    			 echo "Si";
				    		}else{
				    			 echo "No";
				    		}echo"</td>
  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function cliente(){
	echo "
<title>Productos</title>
<h1>Productos</h1>

<table width='1100' border='1'>
  <tr>


                                <th width='200' scope='col'>Rut</th>
                <th width='102' scope='col'>DV</th>
                <th width='102' scope='col'>Nombre</th>
                <th width='102' scope='col'>Direccion</th>
                <th width='102' scope='col'>Comuna</th>
                <th width='102' scope='col'>Ciudad</th>
                <th width='102' scope='col'>Telefono</th>
                <th width='102' scope='col'>Email</th>
                <th width='102' scope='col'>Fax</th>
                <th width='102' scope='col'>Giro</th>
  ";
 global $consulta;//
$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>

                
								<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
                <td>$row[3]</td>
                <td>$row[4]</td>
                <td>$row[5]</td>
                <td>$row[6]</td>
                <td>$row[7]</td>
                <td>$row[8]</td>
                <td>$row[9]</td>

  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
function producto(){
	echo "
<title>Clientes Registrados</title>
<h1>Clientes Registrados</h1>

<table width='1100' border='1'>
  <tr>
                <th width='200' scope='col'>Codigo Barra</th>
                <th width='102' scope='col'>Codigo</th>
                <th width='102' scope='col'>Decripcion Corta</th>
                <th width='102' scope='col'>Descripcion Larga</th>
  ";
  session_start();
$consulta=$_SESSION["ultima_consulta"];
echo $consulta;
$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
echo "		
  <tr>
				<td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[2]</td>
                <td>$row[3]</td>

  </tr>
";
	}
echo "
</table>
<br>
<a href='../menu.php' id='volver'><img src='../images/icon_dashboard.png'></a>
";	

}
}
?>

<?php
if(isset($_POST["imprimir_productos"])){
	$consulta=$_POST["ultima_consulta"];
	producto($consulta);
}
switch ($subsec) {
	case 'proveedor':
	proveedor();	
		break;
	case "categorias":
	categoria();
	break;
	case "subcategorias":
	subcategoria();
	break;
	case "sucursales":
	sucursal();
	break;
	case "cajas":
	caja();
	break;
	case "cajeros":
	cajero();
	break;
	case "envases":
	envase();
	break;
	case "bodegas":
	bodega();
	break;
	case "formas_pagos":
	pago();
	break;
	case "clientes":
	cliente();
	break;
	case "productos":
	producto();
	break;
	
}
?>